package com.nbsaas.boot.order.ext.resource;

import com.nbsaas.boot.order.data.repository.OrderRepository;
import com.nbsaas.boot.order.ext.apis.OrderExtApi;
import com.nbsaas.boot.order.ext.domain.request.OrderExtRequest;
import com.nbsaas.boot.rest.response.ResponseObject;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.math.BigDecimal;


@Service
public class OrderExtResource implements OrderExtApi {

    @Resource
    private OrderRepository orderRepository;

    @Transactional(readOnly = true)
    @Override
    public ResponseObject<BigDecimal> sum() {
        ResponseObject<BigDecimal> result=new ResponseObject<>();
        result.setData(orderRepository.sumAmount());
        return result;
    }

    @Transactional
    @Override
    public ResponseObject<?> create(OrderExtRequest request) {
        ResponseObject<?> result=new ResponseObject<>();

        return result;
    }
}
